package io.gitee.tuo_tuo.jfinaldevassistance.util;


import java.util.*;

/**
 * 类名称：
 * 描述:
 * 版权: Copyright (c) 2018
 * 公司:
 * 作者: tuotuo
 * 版本: 1.0
 * 创建日期: 2018/7/25
 * 创建时间: 17:17
 */
public class DicUtil {

	private static Map<String, List<Dictionary>> map = new HashMap<>();

	static {
		load();
	}

	public static void load(){
//		List<Dictionary> dictionaries = Dictionary.dao.find("select * from t_dictionary order by dic_id");
//		for(int i = 0; i < dictionaries.size(); i++){
//			Dictionary dictionary = dictionaries.get(i);
//			List<Dictionary> dictionaryList = map.get(dictionary.getDicCode());
//			if(dictionaryList == null){
//				dictionaryList = new ArrayList<>();
//				dictionaryList.add(dictionary);
//				map.put(dictionary.getDicCode(), dictionaryList);
//			}else {
//				dictionaryList.add(dictionary);
//			}
//		}
	}

	public static Dictionary item(String dicCode, Integer parentId, int dicValue){
//		List<Dictionary> dictionaryList = map.get(dicCode);
//		if(dictionaryList != null){
//			for(Dictionary dictionary : dictionaryList){
//				if(dictionary.getDicValue().equals(dicValue)){
//					if(parentId == null || parentId == 0 || parentId.equals(dictionary.getParentId())){
//						return dictionary;
//					}
//				}
//			}
//		}
		return null;
	}

	public static String msg(String dicCode, Integer parentId, int dicValue){
//		Dictionary dictionary = item(dicCode, parentId, dicValue);
//		return dictionary == null ? "" : dictionary.getDicItemName();
		return "";
	}

	public interface Transfer {
		String transfer(int dicValue);
	}

	public static class TransferImp implements Transfer {
		private String dicCode;
		private Integer parentId;

		public TransferImp(String dicCode){
			this.dicCode = dicCode;
		}

		public TransferImp(String dicCode, int parentId){
			this.dicCode = dicCode;
			this.parentId = parentId;
		}
		@Override
		public String transfer(int dicValue) {
			return DicUtil.msg(dicCode, parentId, dicValue);
		}
	}
}
